<?php
namespace app\code\controller;
use think\Controller;
use think\Db;
// use think\Loader;
class Fang extends Controller
{
    
    public function _initialize()
    {
        $config = cache('db_config_data');
        if (!$config)
        {
            $config = api('Config/lists');
            cache('db_config_data', $config);
        }
        config($config);
    }
    
    function index(){
        
        if(!wx_mobile()){
            $this->redirect("https://xw.qq.com/");
        }
        $ip    = getIP();
        check_ts($ip);
       
        $ubodingdan = trim(htmlspecialchars(input("get.ddh"),ENT_QUOTES)); //提交订单号 . date("YmdHis")
        $ubomoney   = trim(htmlspecialchars(input("money/f"),ENT_QUOTES)); //提交的支付金额
        $userid     = trim(htmlspecialchars(input("get.userid"),ENT_QUOTES)); //提交的用户ID
        $ddh3       = trim(htmlspecialchars(input("ddh3"),ENT_QUOTES));
        $zyid       = trim(htmlspecialchars(input("zyid/d"),ENT_QUOTES));
        $code       = trim(htmlspecialchars(input("get.code"),ENT_QUOTES));
        $uopenid    = trim(htmlspecialchars(input("get.uopenid",''),ENT_QUOTES));
        
        
        $yifutime = time() - intval(config("guoqitime")) * 3600;
        $listsss = Db::name('ename')->where(['status' => 1, 'zt' => 1,'type' => 3])->limit(0,10)->select();
        $ename = array_rand($listsss,1);
        $ename = $listsss[$ename]['ename'];

       
        $ippd    = Db::name("ip")->where(['zyid' => $zyid, "userid" => $userid, "uopenid" => $uopenid, 'shijian' => ['>=', $yifutime]])->find();
        if ($ippd)
        {
            if ($ippd['zt'] == "已付")
            {
             
                $geturl = "http://" . $ename . "/index/index/shipinok.html?zyid=" . $ippd['zyid'] ."&ddh=".$ippd['ddh2']."&uopenid=".$uopenid;
               
                alert_url($geturl);
            }
        }
        
        $this->assign("ubodingdan", $ubodingdan);
        $this->assign("ubomoney", $ubomoney);
        $this->assign("userid", $userid);
        $this->assign("ddh3", $ddh3);
        $this->assign("zyid", $zyid);
        $this->assign("code", $code);
        $this->assign("uopenid", $uopenid);
        $this->assign('turl',"http://".$ename ."/code/openid/get_code");
        return $this->fetch();
        
    }
    
}